package wpwork.config;

import cn.dev33.satoken.config.SaTokenConfig;
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.stp.StpLogic;
import wpwork.consts.AuthConsts;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;


/**
 *
 * @author wpwork开发平台组
 * @copyright 武汉维普科技有限公司
 */
@Configuration
@EnableConfigurationProperties(wpworkOauthConfig.class)
public class AuthAutoConfigration {


    @Primary
    @Bean
    @ConfigurationProperties(prefix = "oauth.login")
    public SaTokenConfig getWpworkTokenConfig() {
        return new wpworkTokenConfig();
    }

    @Primary
    @Bean(AuthConsts.ACCOUNT_LOGIC_BEAN_DEFAULT)
    public StpLogic getWpworkTokenJwtLogic() {
        return new StpLogicJwtForSimple(AuthConsts.ACCOUNT_TYPE_DEFAULT);
    }

    @Bean(AuthConsts.ACCOUNT_LOGIC_BEAN_TENANT)
    public StpLogic getWpworkTenantTokenJwtLogic() {
        return new StpLogicJwtForSimple(AuthConsts.ACCOUNT_TYPE_TENANT);
    }
}
